// pages/train/learning-link/learningLink.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userClassify: '', // 训练或主流程
    sceneId: '', // 训练场景id
    sceneName: '', // 场景名称
    playingIdx: 0, // 正在播放的序号
    totalRound: 0, // 总环节数
    customerSex: '', // 客户性别，用于对话中的声音
    trainSceneId: '',
    recordType: '',
    isRecommended: 'N',
    levelId: '',
    trainingLibraryId: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const { sceneId, sceneName,trainSceneId, levelId,recordType,isRecommended, description, descInfo, userClassify, customerSex = 'female', from, trainingLibraryId = '', coachingContentId = '' } = options
    console.log('options',options)
    this.setData({
      sceneId,
      sceneName,
      userClassify,
      customerSex,
      from,
      trainingLibraryId,
      trainSceneId,
      levelId,
      recordType,
      coachingContentId,
      isRecommended
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  train () {
    const { sceneId, sceneName,trainSceneId,levelId, userClassify, customerSex, trainingLibraryId,isRecommended, coachingContentId, from } = this.data
    console.log(levelId)
    const type = 'train'
    wx.redirectTo({
      url: `/pages/train/only-train/onlyTrain?sceneId=${sceneId}&sceneName=${sceneName}&userClassify=${userClassify}&isRecommended=${isRecommended}&customerSex=${customerSex}&coachingContentId=${coachingContentId}&levelId=${levelId}&trainingLibraryId=${trainingLibraryId}&trainSceneId=${trainSceneId}&type=${type}&from=${from}`
    })
  },
  setRound (e) {
    this.setData({
      totalRound: e.detail.totalRound
    })
  },
  setPlayIdx (e) {
    this.setData({
      playingIdx: e.detail.index
    })
  },
})